package com.gary.security.repository;

import java.util.List;

import org.springframework.security.acls.Permission;
import org.springframework.security.acls.sid.Sid;
import org.springframework.security.userdetails.UserDetails;

import com.gary.core.repository.BaseRepository;
import com.gary.security.model.UserInfo;


public interface UserRepository extends BaseRepository<UserInfo> {
    /**
     * 根据用户名和密码获得登陆的用户.
     *
     * @param loginId 用户名
     * @param password 密码
     * @return User 登陆用户
     */
    public UserInfo getUserByLoginidAndPasswd(String loginId, String password);

    /**
     * 根据用户名，从缓存中删除用户.
     *
     * @param username 用户名
     */
    public void removeUserInCache(String username);

    /**
     * 添加权限.
     *
     * @param user User
     * @param recipient Sid
     * @param permission Permission
     */
    public void addPermission(UserInfo user, Sid recipient,Permission permission);

    /**
     * 删除权限.
     *
     * @param user User
     * @param recipient Sid
     * @param permission Permission
     */
    public void deletePermission(UserInfo user, Sid recipient,Permission permission);
    
    /**
     * 获取所有用户实例.
     *
     * @see com.AuthenticationRepository.security.service.AuthenticationService#getUsers()
     * @return List
     */
    public List<UserDetails> getUsers(String rolePrefix);

}
